package basic.xiazheng;


import leetcode.Solution1790;
import leetcode.Solution3;
import leetcode.Solution0433;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;

/**
 * @创建人 mby381
 * @创建时间 2022/3/7
 * @描述
 */
public class MyDemo {
    /**
     * @param args
     */
    public static void main(String[] args) {
        System.out.println("FUCK YOU JAVA");
        zax();
        calculate();
        zax();
        hashset();
        zax();
        Color c1 = Color.GREEN;
        System.out.println(c1);
        zax();
        for (Color color : Color.values()) {
            System.out.print(color + "  ");
        }
        System.out.println();
        zax();
        Character[] charArray = {'H', 'E', 'L', 'L', 'O'};
        printArray(charArray);
        zax();
        indexTest();
        zax();
        Alist();
        zax();
        System.out.println("最终答案为" + Solution3.lengthOfLongestSubstring("auwreeeeeewrwrwedsrthkio"));
        zax();
        Solution1790 a = new Solution1790();
        System.out.print("a.areAlmostEqual(mby,zzq):  ");
        System.out.print(a.areAlmostEqual("mby", "zzq"));
        zax();
        String[] temp = {"AACCGATT", "AACCGATA", "AAACGATA", "AAACGGTA"};
        System.out.println(Solution0433.minMutation("AACCGGTT", "AAACGGTA", temp));
        Solution.mydemo m = new Solution.mydemo();
        m.run();
        Solution s = new Solution("zzq");
        Solution.Kat k = s.new Kat("mby");
    }

    public static void calculate() {
        int a = 10;
        int b = 20;
        int c = 25;
        int d = 25;
        System.out.println("a + b = " + (a + b));
        System.out.println("a - b = " + (a - b));
        System.out.println("a * b = " + (a * b));
        System.out.println("b / a = " + (b / a));
        System.out.println("b % a = " + (b % a));
        System.out.println("c % a = " + (c % a));
        System.out.println("a++   = " + (a++));
        System.out.println("a--   = " + (a--));
        System.out.println("d++   = " + (d++));
        System.out.println("++d   = " + (++d));
    }

    public static void hashset() {
        HashSet<String> sites = new HashSet<>();
        sites.add("Google");
        sites.add("Tencent");
        sites.add("Ali");
        sites.add("ByteDance");
        sites.add("Ali");
        System.out.println(sites);
    }

    public static void zax() {
        System.out.println("\n=====================\n");
    }

    public static <E> void printArray(E[] inputArray) {
        for (E element : inputArray) {
            System.out.printf("%s ", element);
        }
        System.out.println();
    }

    public static int findMiddleIndex(int[] nums) {
        int lsum = 0, rsum = 0;
        if (nums.length < 3) {
            return -1;
        }
        for (int i = 0; i < nums.length; i++) {
            for (int j = 0; j < i; j++) {
                lsum += nums[j];
            }
            for (int k = i + 1; k < nums.length; k++) {
                rsum += nums[k];
            }
            if (i == 0) {
                lsum = 0;
            } else if (i == nums.length - 1) {
                rsum = 0;
            }
            if (lsum == rsum) {
                return i;
            } else {
                lsum = 0;
                rsum = 0;
            }
        }
        return -1;
    }

    public static void indexTest() {
        int[] nums = new int[5];
        nums[0] = 1;
        nums[1] = 1;
        nums[2] = 1;
        nums[3] = 1;
        nums[4] = 1;
        System.out.println(findMiddleIndex(nums));
    }

    public static void Alist() {
        ArrayList<Integer> myNumbers = new ArrayList<Integer>();
        myNumbers.add(33);
        myNumbers.add(15);
        myNumbers.add(20);
        myNumbers.add(34);
        myNumbers.add(8);
        myNumbers.add(12);
        Collections.sort(myNumbers);
        for (int i : myNumbers) {
            System.out.println(i);
        }
    }

    enum Color {
        RED, GREEN, BLUE
    }


}

class Solution {
    private String name;

    public Solution() {
        System.out.println("这是一个构造方法");
    }

    public Solution(String s) {
        this.name = s;
        System.out.println("此类名为" + s);
        this.run();
    }

    public void run() {
        System.out.println("这个类正在被使用");
    }

    static class mydemo extends Solution {
        @Override
        public void run() {
            System.out.println("  WTF");
        }
    }

    class Kat {
        private String name;

        public Kat(String s) {
            this.name = s;
            System.out.println("myname:" + this.name);
        }
    }
}
